Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
* mln/trace/warning.hh: new file.
* mln/trace/all.hh: include warning.hh.
* mln/trace/resume.hh,
* mln/trace/stop.hh: cleanup includes.
* mln/debug/put_word.hh: use trace::warning.
---
milena/ChangeLog | 14 ++++++++++++++
milena/mln/debug/put_word.hh | 5 +++--
milena/mln/trace/all.hh | 1 +
milena/mln/trace/resume.hh | 3 ---
milena/mln/trace/stop.hh | 1 -
milena/mln/trace/{stop.hh => warning.hh} | 24 ++++++++++++------------
6 files changed, 30 insertions(+), 18 deletions(-)
copy milena/mln/trace/{stop.hh => warning.hh} (78%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 151dd22..80c3f74 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,17 @@
+2008-11-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add trace::warning.
+
+ * mln/trace/warning.hh: new file.
+
+ * mln/trace/all.hh: include warning.hh.
+
+ * mln/trace/resume.hh,
+ * mln/trace/stop.hh: cleanup includes.
+
+ * mln/debug/put_word.hh: use trace::warning.
+
+
2008-10-30 Guillaume Lazzara <z(a)lrde.epita.fr>
Improve trace output.
diff --git a/milena/mln/debug/put_word.hh b/milena/mln/debug/put_word.hh
index 4380e8d..d494c89 100644
--- a/milena/mln/debug/put_word.hh
+++ b/milena/mln/debug/put_word.hh
@@ -63,11 +63,12 @@ namespace mln
point2d word_end = word_start;
word_end.last_coord() += word.length() - 1;
- mln_precondition(inout.has(word_end));
+ if (!inout.has(word_end))
+ trace::warning("Cannot write text outside the image domain");
const unsigned n = word.length();
point2d p = word_start;
- for (unsigned i = 0; i < n; ++i)
+ for (unsigned i = 0; i < n && inout.has(p); ++i)
{
inout(p) = word[i];
p += right;
diff --git a/milena/mln/trace/all.hh b/milena/mln/trace/all.hh
index 62b9a60..7380f31 100644
--- a/milena/mln/trace/all.hh
+++ b/milena/mln/trace/all.hh
@@ -48,6 +48,7 @@ namespace mln
# include <mln/trace/exiting.hh>
# include <mln/trace/stop.hh>
# include <mln/trace/resume.hh>
+# include <mln/trace/warning.hh>
#endif // ! MLN_TRACE_ALL_HH
diff --git a/milena/mln/trace/resume.hh b/milena/mln/trace/resume.hh
index 3520bd6..7c789ff 100644
--- a/milena/mln/trace/resume.hh
+++ b/milena/mln/trace/resume.hh
@@ -33,9 +33,6 @@
/// Resume traces.
/// \sa mln::trace::stop
-# include <string>
-# include <iostream>
-
# include <mln/trace/quiet.hh>
diff --git a/milena/mln/trace/stop.hh b/milena/mln/trace/stop.hh
index e810c97..4a53dc6 100644
--- a/milena/mln/trace/stop.hh
+++ b/milena/mln/trace/stop.hh
@@ -32,7 +32,6 @@
/// Stop printing traces except if trace::full_trace is enabled.
/// \sa mln::trace::resume
-# include <string>
# include <iostream>
# include <mln/trace/quiet.hh>
diff --git a/milena/mln/trace/stop.hh b/milena/mln/trace/warning.hh
similarity index 78%
copy from milena/mln/trace/stop.hh
copy to milena/mln/trace/warning.hh
index e810c97..c130da6 100644
--- a/milena/mln/trace/stop.hh
+++ b/milena/mln/trace/warning.hh
@@ -16,7 +16,7 @@
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
-// software library without restriction. Specificstopy, if other files
+// software library without restriction. Specificwarningy, 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
@@ -25,12 +25,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_TRACE_STOP_HH
-# define MLN_TRACE_STOP_HH
+#ifndef MLN_TRACE_WARNING_HH
+# define MLN_TRACE_WARNING_HH
-/// \file mln/trace/stop.hh
-/// Stop printing traces except if trace::full_trace is enabled.
-/// \sa mln::trace::resume
+/// \file mln/trace/warning.hh
+/// Display warning message in trace output.
# include <string>
# include <iostream>
@@ -44,16 +43,17 @@ namespace mln
namespace trace
{
- void stop();
+ void warning(const std::string& message);
# ifndef MLN_INCLUDE_ONLY
inline
- void stop()
+ void warning(const std::string& message)
{
- internal::is_quiet = quiet;
- if (!full_trace)
- quiet = true;
+ if (!quiet)
+ std::cout << "Warning: "
+ << message
+ << std::endl;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -63,4 +63,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_TRACE_STOP_HH
+#endif // ! MLN_TRACE_WARNING_HH
--
1.5.6.5
1
0
* mln/trace/entering.hh,
* mln/trace/exiting.hh,
* mln/trace/quiet.hh:
Avoid useless ends of line and add a timer.
---
milena/ChangeLog | 9 +++++++++
milena/mln/trace/entering.hh | 10 ++++++++--
milena/mln/trace/exiting.hh | 25 +++++++++++++++++++++----
milena/mln/trace/quiet.hh | 5 +++++
4 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8dfe0f2..151dd22 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2008-10-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Improve trace output.
+
+ * mln/trace/entering.hh,
+ * mln/trace/exiting.hh,
+ * mln/trace/quiet.hh:
+ Avoid useless ends of line and add a timer.
+
+2008-10-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add trace::stop and trace::resume.
* mln/trace/all.hh: add new includes.
diff --git a/milena/mln/trace/entering.hh b/milena/mln/trace/entering.hh
index 3737a1c..20fc58d 100644
--- a/milena/mln/trace/entering.hh
+++ b/milena/mln/trace/entering.hh
@@ -54,10 +54,16 @@ namespace mln
{
if (quiet)
return;
+
+ if ((tab != 0) && (internal::max_tab == tab))
+ std::cout << std::endl;
+
for (unsigned i = 0; i < tab; ++i)
std::cout << " ";
- std::cout << scope << " {" << std::endl;
- ++tab;
+ std::cout << scope << " {";
+
+ internal::max_tab = ++tab;
+ gettimeofday(&internal::start_time, 0);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/trace/exiting.hh b/milena/mln/trace/exiting.hh
index 4ea9afb..9b7e9f5 100644
--- a/milena/mln/trace/exiting.hh
+++ b/milena/mln/trace/exiting.hh
@@ -50,14 +50,31 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
inline
- void exiting(const std::string& str)
+ void exiting(const std::string& scope)
{
if (quiet)
return;
+
+ timeval after_time;
+ gettimeofday(&after_time, 0);
+ bool has_inner_trace = (internal::max_tab == tab);
--tab;
- for (unsigned i = 0; i < tab; ++i)
- std::cout << " ";
- std::cout << "} " << str << std::endl;
+
+ if (!has_inner_trace)
+ for (unsigned i = 0; i < tab; ++i)
+ std::cout << " ";
+
+ std::cout << "} ";
+
+ if (!has_inner_trace)
+ std::cout << scope << " ";
+
+ std::cout << "- "
+ << (after_time.tv_usec - internal::start_time.tv_usec) / 1000.
+ << "ms ";
+
+ if (has_inner_trace || (internal::max_tab - tab > 1))
+ std::cout << std::endl;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/trace/quiet.hh b/milena/mln/trace/quiet.hh
index 0a98bd4..e7467f0 100644
--- a/milena/mln/trace/quiet.hh
+++ b/milena/mln/trace/quiet.hh
@@ -33,6 +33,8 @@
* \brief Definition of the trace quiet Boolean value.
*/
+# include <ctime>
+# include <sys/time.h>
namespace mln
{
@@ -44,9 +46,12 @@ namespace mln
static unsigned tab = 0;
static bool full_trace = false;
+
namespace internal
{
+ static unsigned max_tab = 0;
+ static timeval start_time;
static bool is_quiet = quiet;
} // end of namespace mln::trace::internal
--
1.5.6.5
1
0
* mln/trace/all.hh: add new includes.
* mln/trace/entering.hh: update copyright.
* mln/trace/quiet.hh: Add new variables.
* mln/trace/resume.hh,
* mln/trace/stop.hh: new routines.
* mln/core/routine/initialize.hh: Use trace::stop and trace::resume.
---
milena/ChangeLog | 14 ++++++++++++
milena/mln/core/routine/initialize.hh | 4 ++-
milena/mln/trace/all.hh | 4 ++-
milena/mln/trace/entering.hh | 2 +-
milena/mln/trace/quiet.hh | 10 ++++++++-
milena/mln/trace/{entering.hh => resume.hh} | 29 ++++++++++---------------
milena/mln/trace/{entering.hh => stop.hh} | 30 +++++++++++---------------
7 files changed, 55 insertions(+), 38 deletions(-)
copy milena/mln/trace/{entering.hh => resume.hh} (72%)
copy milena/mln/trace/{entering.hh => stop.hh} (72%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ffec9ad..8dfe0f2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,19 @@
2008-10-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add trace::stop and trace::resume.
+
+ * mln/trace/all.hh: add new includes.
+ * mln/trace/entering.hh: update copyright.
+ * mln/trace/quiet.hh: Add new variables.
+
+ * mln/trace/resume.hh,
+ * mln/trace/stop.hh: new routines.
+
+ * mln/core/routine/initialize.hh: Use trace::stop and trace::resume.
+
+
+2008-10-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add more colors and fix global constants initialization in mln/values
* mln/literal/colors.hh,
diff --git a/milena/mln/core/routine/initialize.hh b/milena/mln/core/routine/initialize.hh
index ffd9c85..37d6d58 100644
--- a/milena/mln/core/routine/initialize.hh
+++ b/milena/mln/core/routine/initialize.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -61,7 +61,9 @@ namespace mln
mln_precondition(! exact(target).has_data());
mln_precondition(exact(model).has_data());
+ trace::stop();
init_(tag::image, exact(target), exact(model));
+ trace::resume();
mln_postcondition(exact(target).has_data());
trace::exiting("core::initialize");
diff --git a/milena/mln/trace/all.hh b/milena/mln/trace/all.hh
index 01b99c2..62b9a60 100644
--- a/milena/mln/trace/all.hh
+++ b/milena/mln/trace/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -46,6 +46,8 @@ namespace mln
# include <mln/trace/quiet.hh>
# include <mln/trace/entering.hh>
# include <mln/trace/exiting.hh>
+# include <mln/trace/stop.hh>
+# include <mln/trace/resume.hh>
#endif // ! MLN_TRACE_ALL_HH
diff --git a/milena/mln/trace/entering.hh b/milena/mln/trace/entering.hh
index e9d66ce..3737a1c 100644
--- a/milena/mln/trace/entering.hh
+++ b/milena/mln/trace/entering.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
diff --git a/milena/mln/trace/quiet.hh b/milena/mln/trace/quiet.hh
index ef1a00b..0a98bd4 100644
--- a/milena/mln/trace/quiet.hh
+++ b/milena/mln/trace/quiet.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -42,6 +42,14 @@ namespace mln
static bool quiet = true;
static unsigned tab = 0;
+ static bool full_trace = false;
+
+ namespace internal
+ {
+
+ static bool is_quiet = quiet;
+
+ } // end of namespace mln::trace::internal
} // end of namespace mln::trace
diff --git a/milena/mln/trace/entering.hh b/milena/mln/trace/resume.hh
similarity index 72%
copy from milena/mln/trace/entering.hh
copy to milena/mln/trace/resume.hh
index e9d66ce..3520bd6 100644
--- a/milena/mln/trace/entering.hh
+++ b/milena/mln/trace/resume.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -16,7 +16,7 @@
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
-// software library without restriction. Specificenteringy, if other files
+// software library without restriction. Specificresumey, 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
@@ -25,13 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_TRACE_ENTERING_HH
-# define MLN_TRACE_ENTERING_HH
+#ifndef MLN_TRACE_RESUME_HH
+# define MLN_TRACE_RESUME_HH
-/*! \file mln/trace/entering.hh
- *
- * \brief Definition of the trace entering procedure.
- */
+/// \file mln/trace/resume.hh
+///
+/// Resume traces.
+/// \sa mln::trace::stop
# include <string>
# include <iostream>
@@ -45,19 +45,14 @@ namespace mln
namespace trace
{
- void entering(const std::string& scope);
+ void resume();
# ifndef MLN_INCLUDE_ONLY
inline
- void entering(const std::string& scope)
+ void resume()
{
- if (quiet)
- return;
- for (unsigned i = 0; i < tab; ++i)
- std::cout << " ";
- std::cout << scope << " {" << std::endl;
- ++tab;
+ quiet = internal::is_quiet;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -67,4 +62,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_TRACE_ENTERING_HH
+#endif // ! MLN_TRACE_RESUME_HH
diff --git a/milena/mln/trace/entering.hh b/milena/mln/trace/stop.hh
similarity index 72%
copy from milena/mln/trace/entering.hh
copy to milena/mln/trace/stop.hh
index e9d66ce..e810c97 100644
--- a/milena/mln/trace/entering.hh
+++ b/milena/mln/trace/stop.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -16,7 +16,7 @@
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
-// software library without restriction. Specificenteringy, if other files
+// software library without restriction. Specificstopy, 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
@@ -25,13 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_TRACE_ENTERING_HH
-# define MLN_TRACE_ENTERING_HH
+#ifndef MLN_TRACE_STOP_HH
+# define MLN_TRACE_STOP_HH
-/*! \file mln/trace/entering.hh
- *
- * \brief Definition of the trace entering procedure.
- */
+/// \file mln/trace/stop.hh
+/// Stop printing traces except if trace::full_trace is enabled.
+/// \sa mln::trace::resume
# include <string>
# include <iostream>
@@ -45,19 +44,16 @@ namespace mln
namespace trace
{
- void entering(const std::string& scope);
+ void stop();
# ifndef MLN_INCLUDE_ONLY
inline
- void entering(const std::string& scope)
+ void stop()
{
- if (quiet)
- return;
- for (unsigned i = 0; i < tab; ++i)
- std::cout << " ";
- std::cout << scope << " {" << std::endl;
- ++tab;
+ internal::is_quiet = quiet;
+ if (!full_trace)
+ quiet = true;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -67,4 +63,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_TRACE_ENTERING_HH
+#endif // ! MLN_TRACE_STOP_HH
--
1.5.6.5
1
0
2786: Add more colors and fix global constants initialization in mln/values.
by Guillaume Lazzara 04 Nov '08
by Guillaume Lazzara 04 Nov '08
04 Nov '08
* mln/literal/colors.hh,
* mln/literal/grays.hh: Add various new colors.
* mln/literal/black.hh,
* mln/literal/colors.hh,
* mln/literal/grays.hh,
* mln/literal/one.hh,
* mln/literal/origin.hh,
* mln/literal/white.hh,
* mln/literal/zero.hh: Fix the initialization of all the global
constants in literal::* according to ticket #43.
* mln/value/rgb.hh: Add new constructors.
---
milena/ChangeLog | 19 +++++
milena/mln/literal/black.hh | 11 ++-
milena/mln/literal/colors.hh | 140 +++++++++++++++++++++++++++++-----
milena/mln/literal/grays.hh | 27 ++++++-
milena/mln/literal/one.hh | 6 +-
milena/mln/literal/origin.hh | 9 ++-
milena/mln/literal/white.hh | 8 ++-
milena/mln/literal/zero.hh | 7 +-
milena/mln/value/rgb.hh | 173 +++++++++++++++++++++++++++++++++++++-----
9 files changed, 344 insertions(+), 56 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 91eba76..ffec9ad 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,22 @@
+2008-10-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add more colors and fix global constants initialization in mln/values
+
+ * mln/literal/colors.hh,
+ * mln/literal/grays.hh: Add various new colors.
+
+ * mln/literal/black.hh,
+ * mln/literal/colors.hh,
+ * mln/literal/grays.hh,
+ * mln/literal/one.hh,
+ * mln/literal/origin.hh,
+ * mln/literal/white.hh,
+ * mln/literal/zero.hh: Fix the initialization of all the global
+ constants in literal::* according to ticket #43.
+
+ * mln/value/rgb.hh: Add new constructors.
+
+
2008-11-04 Nicolas Ballas <ballas(a)lrde.epita.fr>
Use memcpy_ in level::paste.
diff --git a/milena/mln/literal/black.hh b/milena/mln/literal/black.hh
index 7307420..59e1973 100644
--- a/milena/mln/literal/black.hh
+++ b/milena/mln/literal/black.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -48,8 +48,13 @@ namespace mln
/// Literal black.
- // FIXME: Make this a proper global (issue #43).
- static const black_t black = black_t();
+ extern const black_t& black;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const black_t& black = black_t();
+
+# endif
} // end of namespace mln::literal
diff --git a/milena/mln/literal/colors.hh b/milena/mln/literal/colors.hh
index 069ae59..8e1c135 100644
--- a/milena/mln/literal/colors.hh
+++ b/milena/mln/literal/colors.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -41,51 +41,149 @@ namespace mln
namespace literal
{
+ /// Type of literal red.
+ struct red_t : public Literal<red_t>
+ {
+ };
+
+ /// Type of literal green.
+ struct green_t : public Literal<green_t>
+ {
+ };
+
/// Type of literal blue.
struct blue_t : public Literal<blue_t>
{
};
- /// Type of literal red.
- struct red_t : public Literal<red_t>
+ /// Type of literal brown.
+ struct brown_t : public Literal<brown_t>
{
};
- /// Type of literal dark red.
- struct dark_red_t : public Literal<dark_red_t>
+ /// Type of literal lime.
+ struct lime_t : public Literal<lime_t>
{
};
- /// Type of literal dark orange.
- struct dark_orange_t : public Literal<dark_orange_t>
+ /// Type of literal orange.
+ struct orange_t : public Literal<orange_t>
{
};
- /// Type of literal green.
- struct green_t : public Literal<green_t>
+ /// Type of literal pink.
+ struct pink_t : public Literal<pink_t>
+ {
+ };
+
+ /// Type of literal purple.
+ struct purple_t : public Literal<purple_t>
+ {
+ };
+
+ /// Type of literal teal.
+ struct teal_t : public Literal<teal_t>
{
};
+ /// Type of literal violet.
+ struct violet_t : public Literal<violet_t>
+ {
+ };
- /// Literal red.
- // FIXME: Make this a proper global (issue #43).
- static const red_t red = red_t();
+ /// Type of literal cyan.
+ struct cyan_t : public Literal<cyan_t>
+ {
+ };
+
+ /// Type of literal magenta.
+ struct magenta_t : public Literal<magenta_t>
+ {
+ };
+
+ /// Type of literal yellow.
+ struct yellow_t : public Literal<yellow_t>
+ {
+ };
- /// Literal dark red.
- // FIXME: Make this a proper global (issue #43).
- static const dark_red_t dark_red = dark_red_t();
+ /// Type of literal olive.
+ struct olive_t : public Literal<olive_t>
+ {
+ };
/// Literal red.
- // FIXME: Make this a proper global (issue #43).
- static const dark_orange_t dark_orange = dark_orange_t();
+ extern const red_t& red;
/// Literal green.
- // FIXME: Make this a proper global (issue #43).
- static const green_t green = green_t();
+ extern const green_t& green;
/// Literal blue.
- // FIXME: Make this a proper global (issue #43).
- static const blue_t blue = blue_t();
+ extern const blue_t& blue;
+
+ /// Literal brown.
+ extern const brown_t& brown;
+
+ /// Literal lime.
+ extern const lime_t& lime;
+
+ /// Literal orange.
+ extern const orange_t& orange;
+
+ /// Literal pink.
+ extern const pink_t& pink;
+
+ /// Literal purple.
+ extern const purple_t& purple;
+
+ /// Literal teal.
+ extern const teal_t& teal;
+
+ /// Literal violet.
+ extern const violet_t& violet;
+
+ /// Literal cyan.
+ extern const cyan_t& cyan;
+
+ /// Literal magenta.
+ extern const magenta_t& magenta;
+
+ /// Literal yellow.
+ extern const yellow_t& yellow;
+
+ /// Literal olive.
+ extern const olive_t& olive;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const red_t& red = red_t();
+
+ const green_t& green = green_t();
+
+ const blue_t& blue = blue_t();
+
+ const brown_t& brown = brown_t();
+
+ const lime_t& lime = lime_t();
+
+ const orange_t& orange = orange_t();
+
+ const pink_t& pink = pink_t();
+
+ const purple_t& purple = purple_t();
+
+ const teal_t& teal = teal_t();
+
+ const violet_t& violet = violet_t();
+
+ const cyan_t& cyan = cyan_t();
+
+ const magenta_t& magenta = magenta_t();
+
+ const yellow_t& yellow = yellow_t();
+
+ const olive_t& olive = olive_t();
+
+# endif
} // end of namespace mln::literal
diff --git a/milena/mln/literal/grays.hh b/milena/mln/literal/grays.hh
index b9a6ad6..ba10145 100644
--- a/milena/mln/literal/grays.hh
+++ b/milena/mln/literal/grays.hh
@@ -42,13 +42,36 @@ namespace mln
{
/// Type of literal grays.
+ struct light_gray_t : public Literal<light_gray_t>
+ {
+ };
+
struct medium_gray_t : public Literal<medium_gray_t>
{
};
+ struct dark_gray_t : public Literal<dark_gray_t>
+ {
+ };
+
+ /// Literal light gray.
+ extern const light_gray_t& light_gray;
+
/// Literal medium_gray.
- // FIXME: Make this a proper global (issue #43).
- static const medium_gray_t medium_gray = medium_gray_t();
+ extern const medium_gray_t& medium_gray;
+
+ /// Literal dark gray.
+ extern const dark_gray_t& dark_gray;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const light_gray_t& light_gray = light_gray_t();
+
+ const medium_gray_t& medium_gray = medium_gray_t();
+
+ const dark_gray_t& dark_gray = dark_gray_t();
+
+# endif // !MLN_INCLUDE_ONLY
} // end of namespace mln::literal
diff --git a/milena/mln/literal/one.hh b/milena/mln/literal/one.hh
index 699819f..8176ce2 100644
--- a/milena/mln/literal/one.hh
+++ b/milena/mln/literal/one.hh
@@ -54,8 +54,7 @@ namespace mln
/// Literal one.
- // FIXME: Make this a proper global (issue #43).
- static const one_t one = one_t();
+ extern const one_t& one;
# ifndef MLN_INCLUDE_ONLY
@@ -68,6 +67,9 @@ namespace mln
return 1;
}
+
+ const one_t& one = one_t();
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
diff --git a/milena/mln/literal/origin.hh b/milena/mln/literal/origin.hh
index 5f64726..f4dd1be 100644
--- a/milena/mln/literal/origin.hh
+++ b/milena/mln/literal/origin.hh
@@ -48,8 +48,13 @@ namespace mln
};
/// Literal origin.
- // FIXME: Make this a proper global (issue #43).
- static const origin_t origin = origin_t();
+ extern const origin_t& origin;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const origin_t& origin = origin_t();
+
+# endif
} // end of namespace mln::literal
diff --git a/milena/mln/literal/white.hh b/milena/mln/literal/white.hh
index c8c5bf8..f0e5a52 100644
--- a/milena/mln/literal/white.hh
+++ b/milena/mln/literal/white.hh
@@ -48,9 +48,13 @@ namespace mln
/// Literal white.
- // FIXME: Make this a proper global (issue #43).
- static const white_t white = white_t();
+ extern const white_t& white;
+# ifndef MLN_INCLUDE_ONLY
+
+ const white_t& white = white_t();
+
+# endif
} // end of namespace mln::literal
diff --git a/milena/mln/literal/zero.hh b/milena/mln/literal/zero.hh
index f35f8a3..8762ec1 100644
--- a/milena/mln/literal/zero.hh
+++ b/milena/mln/literal/zero.hh
@@ -54,11 +54,8 @@ namespace mln
operator T () const;
};
-
/// Literal zero.
- // FIXME: Make this a proper global (issue #43).
- static const zero_t zero = zero_t();
-
+ extern const zero_t& zero;
# ifndef MLN_INCLUDE_ONLY
@@ -70,6 +67,8 @@ namespace mln
return 0;
}
+ const zero_t& zero = zero_t();
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh
index 1e3d7ca..fabcf8d 100644
--- a/milena/mln/value/rgb.hh
+++ b/milena/mln/value/rgb.hh
@@ -55,11 +55,24 @@ namespace mln
struct black_t;
struct white_t;
+ struct light_gray_t;
+ struct medium_gray_t;
+ struct dark_gray_t;
+
struct red_t;
- struct dark_red_t;
- struct dark_orange_t;
- struct blue_t;
struct green_t;
+ struct blue_t;
+ struct brown_t;
+ struct lime_t;
+ struct orange_t;
+ struct pink_t;
+ struct purple_t;
+ struct teal_t;
+ struct violet_t;
+ struct cyan_t;
+ struct magenta_t;
+ struct yellow_t;
+ struct olive_t;
/// \}
}
@@ -154,9 +167,8 @@ namespace mln
namespace value
{
- /*! \brief Color class for red-green-blue where every component is
- * n-bit encoded.
- */
+ /// \brief Color class for red-green-blue where every component is
+ /// n-bit encoded.
template <unsigned n>
struct rgb
:
@@ -165,7 +177,7 @@ namespace mln
public internal::value_like_< algebra::vec< 3, int_u<n> >, // Equivalent.
algebra::vec< 3, int_u<n> >, // Encoding.
algebra::vec< 3, int >, // Interoperation.
- rgb<n> > // Exact.
+ rgb<n> > // Exact.
{
public:
@@ -204,11 +216,24 @@ namespace mln
rgb<n>(const mln::literal::white_t&);
rgb<n>(const mln::literal::black_t&);
- rgb<n>(const mln::literal::blue_t&);
+ rgb<n>(const mln::literal::light_gray_t&);
+ rgb<n>(const mln::literal::medium_gray_t&);
+ rgb<n>(const mln::literal::dark_gray_t&);
+
rgb<n>(const mln::literal::red_t&);
- rgb<n>(const mln::literal::dark_red_t&);
- rgb<n>(const mln::literal::dark_orange_t&);
+ rgb<n>(const mln::literal::blue_t&);
rgb<n>(const mln::literal::green_t&);
+ rgb<n>(const mln::literal::brown_t&);
+ rgb<n>(const mln::literal::lime_t&);
+ rgb<n>(const mln::literal::orange_t&);
+ rgb<n>(const mln::literal::pink_t&);
+ rgb<n>(const mln::literal::purple_t&);
+ rgb<n>(const mln::literal::teal_t&);
+ rgb<n>(const mln::literal::violet_t&);
+ rgb<n>(const mln::literal::cyan_t&);
+ rgb<n>(const mln::literal::magenta_t&);
+ rgb<n>(const mln::literal::yellow_t&);
+ rgb<n>(const mln::literal::olive_t&);
/// \}
/// Assignment.
@@ -292,7 +317,7 @@ namespace mln
operator/(const rgb<n>& lhs, const mln::value::scalar_<S>& s);
/// \}
-
+
# ifndef MLN_INCLUDE_ONLY
/*---------------.
@@ -361,6 +386,33 @@ namespace mln
template <unsigned n>
inline
+ rgb<n>::rgb(const mln::literal::light_gray_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>) * 0.75;
+ this->v_[1] = mln_max(int_u<n>) * 0.75;
+ this->v_[2] = mln_max(int_u<n>) * 0.75;
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::medium_gray_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>) * 0.50;
+ this->v_[1] = mln_max(int_u<n>) * 0.50;
+ this->v_[2] = mln_max(int_u<n>) * 0.50;
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::dark_gray_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>) * 0.25;
+ this->v_[1] = mln_max(int_u<n>) * 0.25;
+ this->v_[2] = mln_max(int_u<n>) * 0.25;
+ }
+
+ template <unsigned n>
+ inline
rgb<n>::rgb(const mln::literal::red_t&)
{
this->v_[0] = mln_max(int_u<n>);
@@ -370,42 +422,123 @@ namespace mln
template <unsigned n>
inline
- rgb<n>::rgb(const mln::literal::dark_red_t&)
+ rgb<n>::rgb(const mln::literal::green_t&)
+ {
+ this->v_[0] = 0;
+ this->v_[1] = mln_max(int_u<n>);
+ this->v_[2] = 0;
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::blue_t&)
{
- this->v_[0] = mln_max(int_u<n>) / 3;
+ this->v_[0] = 0;
this->v_[1] = 0;
+ this->v_[2] = mln_max(int_u<n>);
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::brown_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>) * 0.75;
+ this->v_[1] = mln_max(int_u<n>) * 0.50;
+ this->v_[2] = mln_max(int_u<n>) * 0.25;
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::lime_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>) * 0.75;
+ this->v_[1] = mln_max(int_u<n>);
this->v_[2] = 0;
}
template <unsigned n>
inline
- rgb<n>::rgb(const mln::literal::dark_orange_t&)
+ rgb<n>::rgb(const mln::literal::orange_t&)
{
- this->v_[0] = mln_max(int_u<n>) / 3;
- this->v_[1] = mln_max(int_u<n>) / 3;
+ this->v_[0] = mln_max(int_u<n>);
+ this->v_[1] = mln_max(int_u<n>) * 0.50;
this->v_[2] = 0;
}
template <unsigned n>
inline
- rgb<n>::rgb(const mln::literal::green_t&)
+ rgb<n>::rgb(const mln::literal::pink_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>);
+ this->v_[1] = mln_max(int_u<n>) * 0.75;
+ this->v_[2] = mln_max(int_u<n>) * 0.75;
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::purple_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>) * 0.75;
+ this->v_[1] = 0;
+ this->v_[2] = mln_max(int_u<n>) * 0.25;
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::teal_t&)
{
this->v_[0] = 0;
- this->v_[1] = mln_max(int_u<n>);
- this->v_[2] = 0;
+ this->v_[1] = mln_max(int_u<n>) * 0.50;
+ this->v_[2] = mln_max(int_u<n>) * 0.50;
}
template <unsigned n>
inline
- rgb<n>::rgb(const mln::literal::blue_t&)
+ rgb<n>::rgb(const mln::literal::violet_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>) * 0.50;
+ this->v_[1] = 0;
+ this->v_[2] = mln_max(int_u<n>) * 0.50;
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::cyan_t&)
{
this->v_[0] = 0;
+ this->v_[1] = mln_max(int_u<n>);
+ this->v_[2] = mln_max(int_u<n>);
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::magenta_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>);
this->v_[1] = 0;
this->v_[2] = mln_max(int_u<n>);
}
template <unsigned n>
inline
+ rgb<n>::rgb(const mln::literal::yellow_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>);
+ this->v_[1] = mln_max(int_u<n>);
+ this->v_[2] = 0;
+ }
+
+ template <unsigned n>
+ inline
+ rgb<n>::rgb(const mln::literal::olive_t&)
+ {
+ this->v_[0] = mln_max(int_u<n>) * 0.50;
+ this->v_[1] = mln_max(int_u<n>) * 0.50;
+ this->v_[2] = 0;
+ }
+
+ template <unsigned n>
+ inline
rgb<n>&
rgb<n>::operator=(const rgb<n>& rhs)
{
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Use memcpy_ in level::paste.
* mln/core/image/image1d.hh: Replace array by buffer in element method.
* mln/level/memcpy_.hh: Replace operator[] by element().
* mln/level/paste.spe.hh: Add paste_fastest and update dispatch.
* mln/level/fill_with_value.spe.hh: Update doc.
core/image/image1d.hh | 4 ++--
level/fill_with_value.spe.hh | 1 -
level/memcpy_.hh | 19 ++++++++++++-------
level/paste.spe.hh | 42 +++++++++++++++++++++++++++++-------------
4 files changed, 43 insertions(+), 23 deletions(-)
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2784)
+++ mln/core/image/image1d.hh (working copy)
@@ -448,7 +448,7 @@
image1d<T>::element(unsigned ind) const
{
mln_precondition(this->has(point1d(ind)));
- return this->data_->array_[ind];
+ return this->data_->buffer_[ind];
}
template <typename T>
@@ -457,7 +457,7 @@
image1d<T>::element(unsigned ind)
{
mln_precondition(this->has(point1d(ind)));
- return this->data_->array_[ind];
+ return this->data_->buffer_[ind];
}
template <typename T>
Index: mln/level/memcpy_.hh
--- mln/level/memcpy_.hh (revision 2784)
+++ mln/level/memcpy_.hh (working copy)
@@ -125,13 +125,18 @@
mln_precondition(dest.ima().has_data());
mln_precondition(src.ima().has_data());
- mln_precondition(&dest.val() >= &dest.ima()[0]);
- mln_precondition(&dest.val() < &dest.ima()[0] + dest.ima().nelements());
- mln_precondition(&dest.val() + n <= &dest.ima()[0] + dest.ima().nelements());
-
- mln_precondition(&src.val() >= &src.ima()[0]);
- mln_precondition(&src.val() < &src.ima()[0] + src.ima().nelements());
- mln_precondition(&src.val() + n <= &src.ima()[0] + src.ima().nelements());
+ mln_precondition(&dest.val() >= &dest.ima().element(0));
+ mln_precondition(&dest.val() < &dest.ima().element(0) +
+ dest.ima().nelements());
+
+ mln_precondition(&dest.val() + n <= &dest.ima().element(0) +
+ dest.ima().nelements());
+
+ mln_precondition(&src.val() >= &src.ima().element(0));
+ mln_precondition(&src.val() < &src.ima().element(0) +
+ src.ima().nelements());
+ mln_precondition(&src.val() + n <= &src.ima().element(0) +
+ src.ima().nelements());
impl::memcpy__(dest, src, n);
Index: mln/level/paste.spe.hh
--- mln/level/paste.spe.hh (revision 2784)
+++ mln/level/paste.spe.hh (working copy)
@@ -39,6 +39,8 @@
# error "Forbidden inclusion of *.spe.hh"
# endif // ! MLN_LEVEL_PASTE_HH
+# include <mln/core/pixel.hh>
+# include <mln/level/fill_with_value.hh>
# include <mln/level/memcpy_.hh>
@@ -114,21 +116,34 @@
trace::entering("level::impl::paste_fast");
}
-
template <typename I, typename J>
- void paste_fast_singleton(const Image<I>& input_, Image<J>& output_)
+ void paste_fastest(const Image<I>& input_, Image<J>& output_)
{
- trace::entering("level::impl::paste_fast_singleton");
+ trace::entering("level::impl::paste_fastest");
const I& input = exact(input_);
J& output = exact(output_);
level::internal::paste_tests(input, output);
- mln_pixter(J) po(output);
+ pixel<const I> src (input);
+ pixel<J> dst(output);
+ *(src.address_()) = input.buffer();
+ *(dst.address_()) = output.buffer();
+
+ memcpy_(dst, src, input.nelements());
+
+ trace::entering("level::impl::paste_fastest");
+ }
+
+ template <typename I, typename J>
+ void paste_singleton(const Image<I>& input_, Image<J>& output_)
+ {
+ trace::entering("level::impl::paste_fast_singleton");
+
+ const I& input = exact(input_);
- for_all(po)
- po.val() = input.val();
+ level::fill_with_value(output_, input.val());
trace::entering("level::impl::paste_fast_singleton");
}
@@ -152,10 +167,10 @@
const I& input = exact(input_);
J& output = exact(output_);
- if (input.domain() == output.domain())
- impl::paste_fast(input, output);
+ if (input.border() == output.border())
+ impl::paste_fastest(input, output);
else
- impl::generic::paste(input, output);
+ impl::paste_fast(input, output);
}
template <typename I, typename J>
@@ -167,7 +182,7 @@
const Image<I>& input,
Image<J>& output)
{
- impl::paste_fast(input, output);
+ impl::paste_fastest(input, output);
}
@@ -196,11 +211,11 @@
template <typename I, typename J>
inline
void paste_(trait::image::value_storage::singleton,
- trait::image::value_storage::one_block,
+ trait::image::value_storage::any,
const Image<I>& input,
Image<J>& output)
{
- impl::paste_fast_singleton(input, output);
+ impl::paste_singleton(input, output);
}
@@ -219,7 +234,8 @@
if (mlc_is(mln_trait_image_value_alignement(I),
trait::image::value_alignement::with_grid)::value &&
mlc_is(mln_trait_image_value_alignement(J),
- trait::image::value_alignement::with_grid)::value)
+ trait::image::value_alignement::with_grid)::value &&
+ input.domain() == output.domain())
{
paste_(mln_trait_image_value_access(I)(),
mln_trait_image_value_access(J)(),
Index: mln/level/fill_with_value.spe.hh
--- mln/level/fill_with_value.spe.hh (revision 2784)
+++ mln/level/fill_with_value.spe.hh (working copy)
@@ -210,7 +210,6 @@
}
- /// FIXME:
// This specialization is only here to deal with image which have
// non-updated properties (vw_io).
template <typename I, typename V>
1
0
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-11-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Fix previous patch.
* mln/morpho/erosion.spe.hh: Remove old code.
---
erosion.spe.hh | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
Index: branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh
===================================================================
--- branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2783)
+++ branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2784)
@@ -1095,13 +1095,9 @@
{
}
- template <typename V>
- void neutral(const V&) { return mln_max(V); }
- void neutral(const bool&) { return true; }
-
void init()
{
- extension::adjust_fill(input, win, neutral(mln_value(I)()));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
1
0
milena r2783: Add accumulator template parameter to all versions of erosion
by Matthieu Garrigues 04 Nov '08
by Matthieu Garrigues 04 Nov '08
04 Nov '08
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-11-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
* mln/morpho/erosion.spe.hh: Add accumulator template parameter to all
versions of erosion.
---
erosion.spe.hh | 146 +++++++++++++++++++++++++++++++++------------------------
1 file changed, 85 insertions(+), 61 deletions(-)
Index: branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh
===================================================================
--- branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2782)
+++ branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2783)
@@ -305,17 +305,17 @@
return output;
}
- template <typename I, typename W>
+ template <typename I, typename W, typename A>
struct erosion_arbitrary_2d_fastest_functor
{
- typedef erosion_arbitrary_2d_fastest_functor<I,W> self;
+ typedef erosion_arbitrary_2d_fastest_functor<I,W,A> self;
typedef void (self::*move_fun)();
typedef mln_deduce(I, psite, delta) dpsite;
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
@@ -346,7 +346,7 @@
erosion_arbitrary_2d_fastest_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
win_left_fwd(win::shift(win, mln::left) - win),
win_right_fwd(win - win::shift(win, mln::left)),
@@ -398,50 +398,50 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
- min.init();
+ accu.init();
p = input.domain().pmin() - dps[0];
mln_qixter(const I, W) q(input, win, p);
for_all(q)
- min.take(q.val());
+ accu.take(q.val());
p = input.domain().pmin();
}
void right()
{
for_all(q_l_fwd)
- min.untake(q_l_fwd.val());
+ accu.untake(q_l_fwd.val());
for_all(q_r_fwd)
- min.take(q_r_fwd.val());
- output(p) = min;
+ accu.take(q_r_fwd.val());
+ output(p) = accu;
}
void left()
{
for_all(q_r_bkd)
- min.untake(q_r_bkd.val());
+ accu.untake(q_r_bkd.val());
for_all(q_l_bkd)
- min.take(q_l_bkd.val());
- output(p) = min;
+ accu.take(q_l_bkd.val());
+ output(p) = accu;
}
void down()
{
for_all(q_top_down)
- min.untake(q_top_down.val());
+ accu.untake(q_top_down.val());
for_all(q_bot_down)
- min.take(q_bot_down.val());
- output(p) = min;
+ accu.take(q_bot_down.val());
+ output(p) = accu;
}
void up()
{
for_all(q_bot_up)
- min.untake(q_bot_up.val());
+ accu.untake(q_bot_up.val());
for_all(q_top_up)
- min.take(q_top_up.val());
- output(p) = min;
+ accu.take(q_top_up.val());
+ output(p) = accu;
}
};
@@ -453,7 +453,11 @@
{
trace::entering("morpho::impl:erosion_arbitrary_2d_fastest");
- typedef erosion_arbitrary_2d_fastest_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_arbitrary_2d_fastest_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::snake_generic(f);
@@ -555,7 +559,7 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
accu.init();
p = input.domain().pmin() - dps[0];
@@ -802,7 +806,7 @@
// Diagonal2d non fastest.
- template <typename I_, typename W>
+ template <typename I_, typename W, typename A>
struct erosion_diagonal2d_functor
{
typedef I_ I;
@@ -811,7 +815,7 @@
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
enum { dim = I::site::dim };
@@ -824,7 +828,7 @@
erosion_diagonal2d_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
dir(dir),
win_left(win::shift(win, dpsite(1, -1)) - win),
win_right(win - win::shift(win, dpsite(1, -1))),
@@ -835,27 +839,27 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
void next()
{
for_all(q_l)
- min.untake(input(q_l));
+ accu.untake(input(q_l));
for_all(q_r)
- min.take(input(q_r));
- output(p) = min;
+ accu.take(input(q_r));
+ output(p) = accu;
}
void init_diag()
{
- min.init();
+ accu.init();
p = p - dpsite(-1, 1);
mln_qiter(W) q(win, p);
for_all(q)
- min.take(input(q));
+ accu.take(input(q));
p = p + dpsite(-1, 1);
}
@@ -873,7 +877,11 @@
{
trace::entering("morpho::impl:erosion_diagonal2d");
- typedef erosion_diagonal2d_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_diagonal2d_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::diagonal2d(f);
@@ -884,7 +892,7 @@
- template <typename I_, typename W>
+ template <typename I_, typename W, typename A>
struct erosion_backdiagonal2d_functor
{
typedef I_ I;
@@ -893,7 +901,7 @@
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
enum { dim = I::site::dim };
@@ -906,7 +914,7 @@
erosion_backdiagonal2d_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
dir(dir),
win_left(win::shift(win, dpsite(-1, -1)) - win),
win_right(win - win::shift(win, dpsite(-1, -1))),
@@ -917,27 +925,27 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
void next()
{
for_all(q_l)
- min.untake(input(q_l));
+ accu.untake(input(q_l));
for_all(q_r)
- min.take(input(q_r));
- output(p) = min;
+ accu.take(input(q_r));
+ output(p) = accu;
}
void init_diag()
{
- min.init();
+ accu.init();
p = p - dpsite(1, 1);
mln_qiter(W) q(win, p);
for_all(q)
- min.take(input(q));
+ accu.take(input(q));
p = p + dpsite(1, 1);
}
@@ -954,7 +962,11 @@
{
trace::entering("morpho::impl:erosion_backdiagonal2d");
- typedef erosion_backdiagonal2d_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_backdiagonal2d_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::backdiagonal2d(f);
@@ -966,7 +978,7 @@
// Diagonal2d fastest.
- template <typename I_, typename W>
+ template <typename I_, typename W, typename A>
struct erosion_diagonal2d_fastest_functor
{
typedef I_ I;
@@ -975,7 +987,7 @@
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
enum { dim = I::site::dim };
@@ -988,7 +1000,7 @@
erosion_diagonal2d_fastest_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
dir(dir),
win_left(win::shift(win, dpsite(1, -1)) - win),
win_right(win - win::shift(win, dpsite(1, -1))),
@@ -999,27 +1011,27 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
void next()
{
for_all(q_l)
- min.untake(q_l.val());
+ accu.untake(q_l.val());
for_all(q_r)
- min.take(q_r.val());
- output(p) = min;
+ accu.take(q_r.val());
+ output(p) = accu;
}
void init_diag()
{
- min.init();
+ accu.init();
p = p - dpsite(-1, 1);
mln_qixter(const I, W) q(input, win, p);
for_all(q)
- min.take(q.val());
+ accu.take(q.val());
p = p + dpsite(-1, 1);
}
@@ -1036,7 +1048,11 @@
{
trace::entering("morpho::impl:erosion_diagonal2d_fastest");
- typedef erosion_diagonal2d_fastest_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_diagonal2d_fastest_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::diagonal2d(f);
@@ -1048,7 +1064,7 @@
// Backdiagonal2d fastest.
- template <typename I_, typename W>
+ template <typename I_, typename W, typename A>
struct erosion_backdiagonal2d_fastest_functor
{
typedef I_ I;
@@ -1057,7 +1073,7 @@
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
enum { dim = I::site::dim };
@@ -1070,7 +1086,7 @@
erosion_backdiagonal2d_fastest_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
dir(dir),
win_left(win::shift(win, dpsite(-1, -1)) - win),
win_right(win - win::shift(win, dpsite(-1, -1))),
@@ -1079,29 +1095,33 @@
{
}
+ template <typename V>
+ void neutral(const V&) { return mln_max(V); }
+ void neutral(const bool&) { return true; }
+
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, neutral(mln_value(I)()));
initialize(output, input);
}
void next()
{
for_all(q_l)
- min.untake(q_l.val());
+ accu.untake(q_l.val());
for_all(q_r)
- min.take(q_r.val());
- output(p) = min;
+ accu.take(q_r.val());
+ output(p) = accu;
}
void init_diag()
{
- min.init();
+ accu.init();
p = p - dpsite(1, 1);
mln_qixter(const I, W) q(input, win, p);
for_all(q)
- min.take(q.val());
+ accu.take(q.val());
p = p + dpsite(1, 1);
}
@@ -1118,7 +1138,11 @@
{
trace::entering("morpho::impl:erosion_backdiagonal2d_fastest");
- typedef erosion_backdiagonal2d_fastest_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_backdiagonal2d_fastest_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::backdiagonal2d(f);
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Fix sanity check.
* tests/all_headers.cc: Fill with every all.hh headers.
* mln/core/image/all.hh: Fix inclusions.
mln/core/image/all.hh | 113 ++++++++++++++++++++++++--------------------------
tests/all_headers.cc | 91 ++++++++++++++++++++++------------------
2 files changed, 106 insertions(+), 98 deletions(-)
Index: tests/all_headers.cc
--- tests/all_headers.cc (revision 2781)
+++ tests/all_headers.cc (working copy)
@@ -30,61 +30,70 @@
* \brief Tests with all headers. (check norris tests)
*/
-
-#include <mln/test/all.hh>
-#include <mln/convert/all.hh>
-#include <mln/estim/all.hh>
-//#include <mln/debug/all.hh>
-#include <mln/histo/all.hh>
-#include <mln/pw/all.hh>
-#include <mln/geom/all.hh>
-#include <mln/core/trait/all.hh>
-#include <mln/fun/i2v/all.hh>
-#include <mln/fun/p2b/all.hh>
+#include <mln/util/all.hh>
#include <mln/fun/p2v/all.hh>
-#include <mln/fun/v2v/all.hh>
#include <mln/fun/x2x/all.hh>
+#include <mln/fun/v2v/all.hh>
+#include <mln/fun/i2v/all.hh>
#include <mln/fun/all.hh>
-#include <mln/math/all.hh>
-#include <mln/set/all.hh>
-#include <mln/draw/all.hh>
-#include <mln/metal/math/all.hh>
-#include <mln/metal/all.hh>
-#include <mln/morpho/all.hh>
+#include <mln/fun/x2v/all.hh>
+#include <mln/fun/p2b/all.hh>
+#include <mln/extension/all.hh>
+#include <mln/histo/all.hh>
+#include <mln/trait/op/all.hh>
+#include <mln/trait/all.hh>
+#include <mln/trait/value/all.hh>
+#include <mln/win/all.hh>
+#include <mln/core/routine/all.hh>
+#include <mln/core/trait/all.hh>
+#include <mln/core/def/all.hh>
+#include <mln/core/internal/check/image_all.hh>
+#include <mln/core/image/all.hh>
+#include <mln/core/site_set/all.hh>
+#include <mln/io/pbm/all.hh>
#include <mln/io/pfm/all.hh>
#include <mln/io/pgm/all.hh>
+#include <mln/io/all.hh>
#include <mln/io/fits/all.hh>
-#include <mln/io/ppm/all.hh>
-#include <mln/io/pbm/all.hh>
#include <mln/io/pnm/all.hh>
-#include <mln/io/all.hh>
-#include <mln/level/naive/all.hh>
-#include <mln/level/approx/all.hh>
-#include <mln/level/all.hh>
-#include <mln/arith/all.hh>
-#include <mln/linear/all.hh>
-#include <mln/logical/all.hh>
+#include <mln/io/ppm/all.hh>
+#include <mln/make/all.hh>
#include <mln/canvas/morpho/all.hh>
-#include <mln/canvas/browsing/all.hh>
#include <mln/canvas/all.hh>
+#include <mln/canvas/browsing/all.hh>
+#include <mln/estim/all.hh>
+#include <mln/arith/all.hh>
+#include <mln/display/all.hh>
+#include <mln/test/all.hh>
+#include <mln/border/all.hh>
+#include <mln/trace/all.hh>
+#include <mln/debug/all.hh>
+#include <mln/morpho/elementary/all.hh>
+#include <mln/morpho/all.hh>
#include <mln/accu/all.hh>
+#include <mln/pw/all.hh>
+#include <mln/linear/all.hh>
+#include <mln/metal/all.hh>
+#include <mln/metal/math/all.hh>
+#include <mln/set/all.hh>
+#include <mln/convert/impl/all.hh>
+#include <mln/convert/all.hh>
+#include <mln/geom/all.hh>
+#include <mln/literal/all.hh>
+#include <mln/level/approx/all.hh>
+#include <mln/level/all.hh>
+#include <mln/level/naive/all.hh>
+#include <mln/math/all.hh>
#include <mln/norm/all.hh>
-#include <mln/value/internal/all.hh>
-#include <mln/value/concept/all.hh>
+#include <mln/logical/all.hh>
+#include <mln/draw/all.hh>
#include <mln/value/builtin/all.hh>
#include <mln/value/all.hh>
-//#include <mln/make/all.hh>
-#include <mln/border/all.hh>
-#include <mln/labeling/all.hh>
-#include <mln/util/all.hh>
-#include <mln/trait/value/all.hh>
-#include <mln/trait/op/all.hh>
-#include <mln/trait/all.hh>
+#include <mln/value/internal/all.hh>
+#include <mln/value/concept/all.hh>
#include <mln/tag/all.hh>
-#include <mln/trace/all.hh>
-#include <mln/literal/all.hh>
-#include <mln/display/all.hh>
-#include <mln/win/all.hh>
+#include <mln/labeling/all.hh>
+
int main ()
Index: mln/core/image/all.hh
--- mln/core/image/all.hh (revision 2781)
+++ mln/core/image/all.hh (working copy)
@@ -36,63 +36,62 @@
*/
-# include <bgraph_image.hh>
-# include <bgraph_psite.hh>
-# include <cast_image.hh>
-# include <ch_piter.hh>
-# include <complex_image.hh>
-# include <complex_neighborhood_piter.hh>
-# include <complex_neighborhoods.hh>
-# include <complex_window_piter.hh>
-# include <complex_windows.hh>
-# include <decorated_image.hh>
-# include <extended.hh>
-# include <extension_fun.hh>
-# include <extension_ima.hh>
-# include <extension_val.hh>
-# include <fi_adaptor.hh>
-# include <flat_image.hh>
-# include <graph_elt_neighborhood.hh>
-# include <graph_elt_window.hh>
-# include <graph_image.hh>
-# include <graph_neighborhood_piter.hh>
-# include <graph_window_piter.hh>
-# include <hexa.hh>
-# include <hexa_piter.hh>
-# include <image1d.hh>
-# include <image2d.hh>
-# include <image2d_h.hh>
-# include <image3d.hh>
-# include <image_if.hh>
-# include <interpolated.hh>
-# include <lazy_image.hh>
-# include <line_graph_elt_neighborhood.hh>
-# include <line_graph_elt_window.hh>
-# include <line_graph_image.hh>
-# include <line_graph_neighborhood_piter.hh>
-# include <line_graph_psite.hh>
-# include <line_graph_window_piter.hh>
-# include <mono_obased_rle_encode.hh>
-# include <mono_obased_rle_image.hh>
-# include <mono_rle_encode.hh>
-# include <mono_rle_image.hh>
-# include <obased_rle_encode.hh>
-# include <obased_rle_image.hh>
-# include <plain.hh>
-# include <rle_encode.hh>
-# include <rle_image.hh>
-# include <safe.hh>
-# include <sparse_encode.hh>
-# include <sparse_image.hh>
-# include <status.txt
-# include <sub_image.hh>
-# include <sub_image_if.hh>
-# include <t_image.hh>
-# include <translate_image.hh>
-# include <tr_image.hh>
-# include <tr_mesh.hh>
-# include <value_enc_image.hh>
-# include <value_encode.hh>
+# 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>
+# include <mln/core/image/complex_neighborhood_piter.hh>
+# include <mln/core/image/complex_neighborhoods.hh>
+# include <mln/core/image/complex_window_piter.hh>
+# include <mln/core/image/complex_windows.hh>
+# include <mln/core/image/decorated_image.hh>
+# include <mln/core/image/extended.hh>
+# include <mln/core/image/extension_fun.hh>
+# include <mln/core/image/extension_ima.hh>
+# include <mln/core/image/extension_val.hh>
+# include <mln/core/image/flat_image.hh>
+# include <mln/core/image/graph_elt_neighborhood.hh>
+# include <mln/core/image/graph_elt_window.hh>
+# include <mln/core/image/graph_image.hh>
+# include <mln/core/image/graph_neighborhood_piter.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_neighborhood.hh>
+# include <mln/core/image/line_graph_elt_window.hh>
+# include <mln/core/image/line_graph_image.hh>
+# include <mln/core/image/line_graph_neighborhood_piter.hh>
+# include <mln/core/image/line_graph_psite.hh>
+# include <mln/core/image/line_graph_window_piter.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/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/sparse_encode.hh>
+# include <mln/core/image/sparse_image.hh>
+# include <mln/core/image/sub_image.hh>
+# include <mln/core/image/sub_image_if.hh>
+# include <mln/core/image/t_image.hh>
+# include <mln/core/image/translate_image.hh>
+# include <mln/core/image/tr_image.hh>
+# include <mln/core/image/tr_mesh.hh>
+# include <mln/core/image/value_enc_image.hh>
+# include <mln/core/image/value_encode.hh>
+//# include <mln/core/image/fi_adaptor.hh>
#endif // ! MLN_CORE_IMAGE_ALL_HH
Index: mln/util/tree_to_image.hh
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Update the transform routine.
* tests/level/transform_full.cc: Update tests.
* mln/level/transform.spe.hh,
* mln/level/transform.hh: Update, output is now directly returned.
* mln/level/stretch.hh: Update.
mln/level/stretch.hh | 2
mln/level/transform.hh | 47 ++----
mln/level/transform.spe.hh | 296 ++++++++++++++++++------------------------
tests/level/transform_full.cc | 4
4 files changed, 147 insertions(+), 202 deletions(-)
Index: tests/level/transform_full.cc
--- tests/level/transform_full.cc (revision 2780)
+++ tests/level/transform_full.cc (working copy)
@@ -76,9 +76,9 @@
{
const I& ref = exact(ref_);
- I out (ref.domain());
+ mln_ch_value(I, mln_result_(mysqrt)) out;
{
- level::transform(ref, mysqrt(), out);
+ out = level::transform(ref, mysqrt());
mln_piter(I) p (ref.domain ());
for_all(p)
mln_assertion ((mln_value(I))(ref(p) % 42) == out(p) );
Index: mln/level/transform.spe.hh
--- mln/level/transform.spe.hh (revision 2780)
+++ mln/level/transform.spe.hh (working copy)
@@ -74,27 +74,29 @@
namespace generic
{
- template <typename I, typename F, typename O>
- void transform(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_);
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform(const Image<I>& input_,
+ const Function_v2v<F>& f_);
}
-
- template <typename I, typename F, typename O>
- void transform_lowq(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_lowq(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_lowq");
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
+
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
level::internal::transform_tests(input, f, output);
- mlc_is(mln_trait_image_pw_io(O),
+ mlc_is(mln_trait_image_pw_io(mln_ch_value(I, mln_result(F))),
trait::image::pw_io::read_write)::check();
value::lut_vec<mln_vset(I), mln_result(F)>
@@ -105,21 +107,26 @@
output(p) = lut(input(p));
trace::exiting("level::impl::transform_lowq");
+
+ return output;
}
- template <typename I, typename F, typename O>
- void transform_taken(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_taken(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_taken");
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
+
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
level::internal::transform_tests(input, f, output);
- mlc_is(mln_trait_image_pw_io(O),
+ mlc_is(mln_trait_image_pw_io(mln_ch_value(I, mln_result(F))),
trait::image::pw_io::read_write)::check();
value::lut_vec<mln_vset(I), mln_result(F)>
@@ -130,47 +137,56 @@
output(p) = lut(input(p));
trace::exiting("level::impl::transform_taken");
+
+ return output;
}
- template <typename I, typename F, typename O>
- void transform_singleton(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_singleton(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_singleton");
const I& input = exact(input_);
const F& f = exact(f_);
- level::internal::transform_tests(input_, f_, output_);
- mln_precondition((mlc_is(mln_trait_image_pw_io(O),
- trait::image::pw_io::read_write)::value ||
- mlc_is(mln_trait_image_vw_io(O),
- trait::image::vw_io::read_write)::value));
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
+
+ level::internal::transform_tests(input_, f_, output);
mln_result(F) val = f(input.val());
- fill_with_value(output_, val);
+ fill_with_value(output, val);
trace::exiting("level::impl::transform_singleton");
+
+ return output;
}
- template <typename I, typename F, typename O>
- void transform_fast(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_fast(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_fast");
+ typedef mln_ch_value(I, mln_result(F)) O;
+
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
+
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
+
level::internal::transform_tests(input, f, output);
mln_pixter(const I) pi(input);
mln_pixter(O) po(output);
-
po.start();
for_all(pi)
{
@@ -179,20 +195,26 @@
}
trace::exiting("level::impl::transform_fast");
+
+ return output;
}
- template <typename I, typename F, typename O>
- void transform_fast_lowq(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_fast_lowq(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_fast_lowq");
+ typedef mln_ch_value(I, mln_result(F)) O;
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
+
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
level::internal::transform_tests(input, f, output);
@@ -210,6 +232,8 @@
}
trace::exiting("level::impl::transform_fast_lowq");
+
+ return output;
}
@@ -220,208 +244,144 @@
{
/// Deal with image not updated
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::undef,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::undef,
mln::trait::image::quant::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- impl::generic::transform(input, f, output);
+ return impl::generic::transform(input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::vw_set::any,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::vw_set::any,
mln::trait::image::quant::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- impl::generic::transform(input, f, output);
+ return impl::generic::transform(input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::vw_set::uni,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::vw_set::uni,
mln::trait::image::quant::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- impl::transform_taken(input, f, output);
+ return impl::transform_taken(input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::vw_set::none,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::vw_set::any,
mln::trait::image::quant::low,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- impl::transform_lowq(input, f, output);
+ return impl::transform_lowq(input, f);
}
- template <typename I, typename F, typename O>
- inline
- void transform_dispatch_(mln::trait::image::quant::any,
- mln::trait::image::value_access::direct,
- mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::some,
- mln::trait::image::ext_domain::some,
- const Image<I>& input_,
- const Function_v2v<F>& f,
- Image<O>& output_)
- {
- const I& input = exact(input_);
- O& output = exact(output_);
-
- if (input.domain() == output.domain())
- transform_fast(input, f, output);
- else
- transform_dispatch_(mln_trait_image_vw_set(I)(),
- mln_trait_image_quant(I)(),
- input, f, output);
- }
-
- template <typename I, typename F, typename O>
+ /// FIXME check that is right
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::quant::any,
- mln::trait::image::value_access::direct,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::quant::any,
mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::none,
- mln::trait::image::ext_domain::none,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_fast(input, f, output);
- }
-
- template <typename I, typename F, typename O>
- inline
- void transform_dispatch_(mln::trait::image::quant::low,
- mln::trait::image::value_access::direct,
- mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::some,
- mln::trait::image::ext_domain::some,
- const Image<I>& input_,
- const Function_v2v<F>& f,
- Image<O>& output_)
- {
- const I& input = exact(input_);
- O& output = exact(output_);
-
- if (input.domain() == output.domain())
- transform_fast_lowq(input, f, output);
- else
- transform_dispatch_(mln_trait_image_vw_set(I)(),
- mln_trait_image_quant(I)(),
- input, f, output);
+ return transform_fast(input, f);
}
- template <typename I, typename F, typename O>
+ /// FIXME check that is right
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::quant::low,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::quant::low,
mln::trait::image::value_access::direct,
- mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::none,
- mln::trait::image::ext_domain::none,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_fast_lowq(input, f, output);
+ return transform_fast_lowq(input, f);
}
- template <typename I, typename F, typename O>
+
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::quant::any,
- mln::trait::image::value_access::any,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::quant::any,
mln::trait::image::value_access::any,
- mln::trait::image::ext_domain::any,
- mln::trait::image::ext_domain::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_dispatch_(mln_trait_image_vw_set(I)(),
+ return transform_dispatch_(mln_trait_image_vw_set(I)(),
mln_trait_image_quant(I)(),
- input, f, output);
+ input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::value_storage::any,
- mln::trait::image::value_storage::any,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::value_storage::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_dispatch_(mln_trait_image_vw_set(I)(),
+ return transform_dispatch_(mln_trait_image_vw_set(I)(),
mln_trait_image_quant(I)(),
- input, f, output);
+ input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::value_storage::singleton,
- mln::trait::image::value_storage::any,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::value_storage::singleton,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_singleton(input, f, output);
+ return transform_singleton(input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::value_storage::one_block,
- mln::trait::image::value_storage::one_block,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::value_storage::one_block,
const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ const Function_v2v<F>& f_)
{
const I& input = exact(input_);
- O& output = exact(output_);
-
- /// Check basic properties
+ /// Check alignement property
if (mlc_is(mln_trait_image_value_alignement(I),
- trait::image::value_alignement::with_grid)::value &&
- mlc_is(mln_trait_image_value_alignement(O),
trait::image::value_alignement::with_grid)::value)
- {
- transform_dispatch_(mln_trait_image_quant(I)(),
+ return transform_dispatch_(mln_trait_image_quant(I)(),
mln_trait_image_value_access(I)(),
- mln_trait_image_value_access(O)(),
- mln_trait_image_ext_domain(I)(),
- mln_trait_image_ext_domain(O)(),
- input, f_, output);
- }
+ input, f_);
else
- transform_dispatch_(mln_trait_image_vw_set(I)(),
+ return transform_dispatch_(mln_trait_image_vw_set(I)(),
mln_trait_image_quant(I)(),
- input, f_, output);
+ input, f_);
}
- template <typename I, typename F, typename O>
- inline
- void transform_dispatch_(const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
- {
- transform_dispatch_(mln_trait_image_value_storage(I)(),
- mln_trait_image_value_storage(O)(),
- input, f, output);
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(const Image<I>& input,
+ const Function_v2v<F>& f)
+ {
+ return transform_dispatch_(mln_trait_image_value_storage(I)(),
+ input, f);
}
}
Index: mln/level/transform.hh
--- mln/level/transform.hh (revision 2780)
+++ mln/level/transform.hh (working copy)
@@ -93,11 +93,10 @@
(void) output;
// Properties check
- // FIXME: Re-activate!
-// mln_precondition((mlc_is(mln_trait_image_pw_io(O),
-// trait::image::pw_io::read_write)::value ||
-// mlc_is(mln_trait_image_vw_io(O),
-// trait::image::vw_io::read_write)::value));
+ mln_precondition((mlc_is(mln_trait_image_pw_io(O),
+ trait::image::pw_io::read_write)::value ||
+ mlc_is(mln_trait_image_vw_io(O),
+ trait::image::vw_io::read_write)::value));
// FIXME Convert test
mlc_converts_to(mln_result(F), mln_value(O))::check();
@@ -118,29 +117,31 @@
{
// Generic implementation.
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform(const Image<I>& input_, const Function_v2v<F>& f_,
- Image<O>& output_)
+ mln_ch_value(I, mln_result(F))
+ transform(const Image<I>& input_, const Function_v2v<F>& f_)
{
trace::entering("level::impl::generic::transform");
-
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
- level::internal::transform_tests(input, f, output);
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
- mlc_is(mln_trait_image_pw_io(O),
+ level::internal::transform_tests(input, f, output);
+ mlc_is(mln_trait_image_pw_io(mln_ch_value(I, mln_result(F))),
trait::image::pw_io::read_write)::check();
mln_piter(I) p(input.domain());
for_all(p)
output(p) = f(input(p));
-
trace::exiting("level::impl::generic::transform");
+
+ return output;
}
} // end of namespace mln::level::impl::generic
@@ -150,21 +151,6 @@
// Facade.
- template <typename I, typename F, typename O>
- inline
- void transform(const Image<I>& input, const Function_v2v<F>& f,
- Image<O>& output)
- {
- trace::entering("level::transform");
-
- mln_precondition(exact(output).domain() >= exact(input).domain());
- impl::internal::transform_dispatch_(exact(input), exact(f), exact(output));
-
- trace::exiting("level::transform");
- }
-
-
-
template <typename I, typename F>
inline
mln_ch_value(I, mln_result(F))
@@ -172,12 +158,11 @@
{
trace::entering("level::transform");
- mln_precondition(exact(input).has_data());
mln_ch_value(I, mln_result(F)) output;
- initialize(output, input);
- transform(input, f, output);
+ output = impl::internal::transform_dispatch_(exact(input), exact(f));
trace::exiting("level::transform");
+
return output;
}
Index: mln/level/stretch.hh
--- mln/level/stretch.hh (revision 2780)
+++ mln/level/stretch.hh (working copy)
@@ -81,7 +81,7 @@
float a = (M - m) / (max - min);
float b = (m * max - M * min) / (max - min);
fun::v2v::linear<float, float, int> f(a, b);
- level::transform(input, f, output);
+ output = level::transform(input, f);
}
trace::exiting("level::impl::stretch");
}
1
0
04 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make convolution return the straightforward type.
* mln/core/concept/object.hh: Add metal include.
* mln/metal/is_not_a.hh: New.
* mln/metal/all.hh: Update.
* mln/metal/is_a.hh (U): Rename as...
(M): ...this; more appropriate.
* mln/linear/ch_convolve.hh: New.
* mln/linear/convolve.hh: Fix return type.
* mln/linear/lap.hh: Update.
* mln/accu/convolve.hh: Add check.
* tests/linear/convolve.cc: Update.
* tests/linear/lap.cc: Update.
mln/accu/convolve.hh | 3 -
mln/core/concept/object.hh | 1
mln/linear/ch_convolve.hh | 92 +++++++++++++++++++++++++++++++++++++++++++++
mln/linear/convolve.hh | 33 +++++++---------
mln/linear/lap.hh | 77 +++++++++++++++++++++++--------------
mln/metal/all.hh | 13 +++---
mln/metal/is_a.hh | 26 ++++++------
mln/metal/is_not_a.hh | 28 +++++--------
tests/linear/convolve.cc | 12 ++---
tests/linear/lap.cc | 11 +++--
10 files changed, 204 insertions(+), 92 deletions(-)
Index: tests/linear/convolve.cc
--- tests/linear/convolve.cc (revision 2779)
+++ tests/linear/convolve.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// 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
@@ -61,11 +62,8 @@
.04, .04, .04, .04, .04,
.04, .04, .04, .04, .04 };
w_window2d_float w = make::w_window2d(ws);
+ image2d<float> tmp = linear::convolve(lena, w);
-// image2d<float> tmp = linear::convolve(lena, w);
-// image2d<int_u8> out = level::transform(tmp, math::round<int_u8>());
-
- image2d<int_u8> out = linear::convolve(lena, w);
-
- io::pgm::save(out, "out.pgm");
+ io::pgm::save(level::transform(tmp, math::round<int_u8>()),
+ "out.pgm");
}
Index: tests/linear/lap.cc
--- tests/linear/lap.cc (revision 2779)
+++ tests/linear/lap.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// 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
@@ -33,9 +34,11 @@
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
#include <mln/border/thickness.hh>
#include <mln/linear/lap.hh>
+#include <mln/level/stretch.hh>
#include "tests/data.hh"
@@ -47,8 +50,8 @@
border::thickness = 1;
- image2d<int_u8> lena;
+ image2d<int_u8> lena, out;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
- image2d<int> tmp(lena.domain());
- linear::lap_4(lena, tmp);
+ level::stretch(linear::lap_4(lena), out);
+ io::pgm::save(out, "out.pgm");
}
Index: mln/core/concept/object.hh
--- mln/core/concept/object.hh (revision 2779)
+++ mln/core/concept/object.hh (working copy)
@@ -45,6 +45,7 @@
// metal
# include <mln/metal/is_a.hh>
+# include <mln/metal/is_not_a.hh>
# include <mln/metal/is.hh>
# include <mln/metal/is_not.hh>
# include <mln/metal/equal.hh>
Index: mln/metal/is_not_a.hh
--- mln/metal/is_not_a.hh (revision 2778)
+++ mln/metal/is_not_a.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -25,18 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_METAL_IS_NOT_HH
-# define MLN_METAL_IS_NOT_HH
+#ifndef MLN_METAL_IS_NOT_A_HH
+# define MLN_METAL_IS_NOT_A_HH
-/*! \file mln/metal/is_not.hh
- *
- * \brief Definition of a type that means "is not".
- */
+/// \file mln/metal/is_not_a.hh
+///
+/// Definition of a type that means "is not a".
-# include <mln/metal/is.hh>
+# include <mln/metal/is_a.hh>
-# define mlc_is_not(T, U) mln::metal::is_not< T, U >
+# define mlc_is_not_a(T, M) mln::metal::is_not_a< T, M >
@@ -46,12 +45,9 @@
namespace metal
{
- /*! \brief "is_not" check.
- *
- * FIXME: Doc!
- */
- template <typename T, typename U>
- struct is_not : not_< is<T, U> >::eval
+ /// "is_not_a" static Boolean expression.
+ template <typename T, template <class> class M>
+ struct is_not_a : not_< is_a<T, M> >::eval
{
};
@@ -60,4 +56,4 @@
} // end of namespace mln
-#endif // ! MLN_METAL_IS_NOT_HH
+#endif // ! MLN_METAL_IS_NOT_A_HH
Property changes on: mln/metal/is_not_a.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/metal/all.hh
--- mln/metal/all.hh (revision 2779)
+++ mln/metal/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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
@@ -28,10 +29,10 @@
#ifndef MLN_METAL_ALL_HH
# define MLN_METAL_ALL_HH
-/*! \file mln/metal/all.hh
- *
- * \brief File that includes all meta-programming tools.
- */
+/// \file mln/metal/all.hh
+///
+/// File that includes all meta-programming tools.
+
namespace mln
{
@@ -61,7 +62,9 @@
# include <mln/metal/converts_to.hh>
# include <mln/metal/is.hh>
+# include <mln/metal/is_not.hh>
# include <mln/metal/is_a.hh>
+# include <mln/metal/is_not_a.hh>
# include <mln/metal/goes_to.hh>
# include <mln/metal/const.hh>
Index: mln/metal/is_a.hh
--- mln/metal/is_a.hh (revision 2779)
+++ mln/metal/is_a.hh (working copy)
@@ -37,14 +37,14 @@
/// \brief Expand to a "metalic" boolean expression stating whether \a
-/// T is a subclass of \a U or not.
+/// T is a subclass of \a M or not.
///
-/// In the current implementation, \a U must be template class with
+/// In the current implementation, \a M must be template class with
/// exactly one, non template parameter.
///
/// This macro is the recommended user interface of the "is_a"
/// facility.
-# define mlc_is_a(T, U) mln::metal::is_a<T, U>
+# define mlc_is_a(T, M) mln::metal::is_a<T, M>
@@ -72,12 +72,12 @@
static T* ptr();
};
- template <typename T, template <class> class U>
+ template <typename T, template <class> class M>
struct helper_is_a_
{
template<class V>
- static yes_ selector(U<V>*);
+ static yes_ selector(M<V>*);
static no_ selector(...);
};
@@ -89,22 +89,22 @@
*
* FIXME: Doc!
*/
- template <typename T, template <class> class U>
- struct is_a : bool_<( sizeof( internal::helper_is_a_< T, U >::selector(internal::make_< T >::ptr()) )
+ template <typename T, template <class> class M>
+ struct is_a : bool_<( sizeof( internal::helper_is_a_< T, M >::selector(internal::make_< T >::ptr()) )
==
sizeof( internal::yes_ ) )>
{};
- template <typename T, template <class> class U>
- struct is_a< const T, U > : is_a< T, U >::eval
+ template <typename T, template <class> class M>
+ struct is_a< const T, M > : is_a< T, M >::eval
{};
- template <typename T, template <class> class U>
- struct is_a< T&, U > : is_a< T, U >::eval
+ template <typename T, template <class> class M>
+ struct is_a< T&, M > : is_a< T, M >::eval
{};
- template <typename T, template <class> class U>
- struct is_a< const T&, U > : is_a< T, U >::eval
+ template <typename T, template <class> class M>
+ struct is_a< const T&, M > : is_a< T, M >::eval
{};
Index: mln/linear/ch_convolve.hh
--- mln/linear/ch_convolve.hh (revision 0)
+++ mln/linear/ch_convolve.hh (revision 0)
@@ -0,0 +1,92 @@
+// Copyright (C) 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_LINEAR_CH_CONVOLVE_HH
+# define MLN_LINEAR_CH_CONVOLVE_HH
+
+/// \file mln/linear/ch_convolve.hh
+///
+/// Define convolution return type.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/core/concept/weighted_window.hh>
+# include <mln/trait/ch_value.hh>
+# include <mln/value/ops.hh>
+
+
+/// Define the result of the convolution of an image with type \p I
+/// with a weighted window of type \p W or weights of type \p W.
+# define mln_ch_convolve(I, W) \
+ typename mln::linear::ch_convolve<I, W>::ret
+
+
+namespace mln
+{
+
+ namespace linear
+ {
+
+ namespace internal
+ {
+
+ template <bool b, /* = true, i.e., W is a Weighted_Window */
+ typename I, typename W>
+ struct ch_convolve_helper
+ {
+ typedef mln_sum_x(mln_value(I), mln_weight(W)) V;
+ typedef mln_ch_value(I, V) ret;
+ };
+
+ template <typename I, typename W>
+ struct ch_convolve_helper<false, I, W>
+ {
+ typedef mln_sum_x(mln_value(I), W) V;
+ typedef mln_ch_value(I, V) ret;
+ };
+
+ } // end of namespace mln::linear::internal
+
+
+ template <typename I, typename W>
+ struct ch_convolve
+ : private mlc_and( mlc_is_a(I, Image),
+ mlc_is_not_a(W, Window) )::check_t
+ {
+ protected:
+ enum { is_w_win = mlc_is_a(W, Weighted_Window)::value };
+ typedef internal::ch_convolve_helper<is_w_win, I, W> helper;
+ public:
+ typedef mlc_ret(helper) ret;
+ };
+
+ } // end of namespace mln::linear
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LINEAR_CH_CONVOLVE_HH
Index: mln/linear/convolve.hh
--- mln/linear/convolve.hh (revision 2779)
+++ mln/linear/convolve.hh (working copy)
@@ -29,18 +29,15 @@
#ifndef MLN_LINEAR_CONVOLVE_HH
# define MLN_LINEAR_CONVOLVE_HH
-/*! \file mln/linear/convolve.hh
- *
- * \brief Convolution.
- *
- * \todo Introduce an accumulator.
- */
+/// \file mln/linear/convolve.hh
+///
+/// Convolution.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/weighted_window.hh>
-# include <mln/extension/adjust_duplicate.hh>
+# include <mln/linear/ch_convolve.hh>
# include <mln/accu/convolve.hh>
-
+# include <mln/extension/adjust_duplicate.hh>
namespace mln
@@ -60,7 +57,7 @@
* \pre output.domain = input.domain
*/
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve(const Image<I>& input, const Weighted_Window<W>& w_win);
@@ -95,7 +92,7 @@
{
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve(const Image<I>& input_,
const Weighted_Window<W>& w_win_)
{
@@ -107,7 +104,7 @@
extension::adjust_duplicate(input, w_win);
- typedef mln_concrete(I) O;
+ typedef mln_ch_convolve(I, W) O;
O output;
initialize(output, input);
@@ -132,7 +129,7 @@
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve_fastest(const Image<I>& input_,
const Weighted_Window<W>& w_win_)
{
@@ -144,7 +141,7 @@
extension::adjust_duplicate(input, w_win);
- typedef mln_concrete(I) O;
+ typedef mln_ch_convolve(I, W) O;
O output;
initialize(output, input);
mln_pixter(O) p_out(output);
@@ -176,7 +173,7 @@
{
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve_dispatch(trait::image::speed::any,
const Image<I>& input,
const Weighted_Window<W>& w_win)
@@ -185,7 +182,7 @@
}
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve_dispatch(trait::image::speed::fastest,
const Image<I>& input,
const Weighted_Window<W>& w_win)
@@ -194,7 +191,7 @@
}
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve_dispatch(const Image<I>& input,
const Weighted_Window<W>& w_win)
{
@@ -208,14 +205,14 @@
// Facade.
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve(const Image<I>& input, const Weighted_Window<W>& w_win)
{
trace::entering("linear::convolve");
internal::convolve_tests(input, w_win);
- mln_concrete(I) output;
+ mln_ch_convolve(I, W) output;
output = internal::convolve_dispatch(mln_trait_image_speed(I)(),
input, w_win);
Index: mln/linear/lap.hh
--- mln/linear/lap.hh (revision 2779)
+++ mln/linear/lap.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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
@@ -46,65 +47,85 @@
// FIXME: Doc!
- template <typename I, typename O>
- void lap_4(const Image<I>& input, Image<O>& output);
-
- template <typename I, typename O>
- void lap_8(const Image<I>& input, Image<O>& output);
-
- template <typename I, typename O>
- void lap_x(const Image<I>& input, Image<O>& output);
-
- template <typename I, typename O>
- void lap_o(const Image<I>& input, Image<O>& output);
+ template <typename I>
+ mln_ch_convolve(I, int)
+ lap_4(const Image<I>& input);
+
+ template <typename I>
+ mln_ch_convolve(I, int)
+ lap_8(const Image<I>& input);
+
+ template <typename I>
+ mln_ch_convolve(I, int)
+ lap_x(const Image<I>& input);
+
+ template <typename I>
+ mln_ch_convolve(I, int)
+ lap_o(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
// Laplacian operators (Cf. Sonka et al., p. 81)
- template <typename I, typename O>
+ template <typename I>
inline
- void lap_4(const Image<I>& input, Image<O>& output)
+ mln_ch_convolve(I, int)
+ lap_4(const Image<I>& input)
{
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::lap_4");
+ mln_precondition(exact(input).has_data());
int ws[] = { 0, 1, 0,
1, -4, 1,
0, 1, 0 };
- convolve(input, make::w_window2d(ws), output);
+ mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
+ trace::exiting("linear::lap_4");
+ return output;
}
- template <typename I, typename O>
+ template <typename I>
inline
- void lap_8(const Image<I>& input, Image<O>& output)
+ mln_ch_convolve(I, int)
+ lap_8(const Image<I>& input)
{
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::lap_8");
+ mln_precondition(exact(input).has_data());
int ws[] = { 1, 1, 1,
1, -8, 1,
1, 1, 1 };
- convolve(input, make::w_window2d(ws), output);
+ mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
+ trace::exiting("linear::lap_8");
+ return output;
}
- template <typename I, typename O>
+ template <typename I>
inline
- void lap_x(const Image<I>& input, Image<O>& output)
+ mln_ch_convolve(I, int)
+ lap_x(const Image<I>& input)
{
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::lap_x");
+ mln_precondition(exact(input).has_data());
int ws[] = { +2, -1, +2,
-1, -4, -1,
+2, -1, +2 };
- convolve(input, make::w_window2d(ws), output);
+ mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
+ trace::exiting("linear::lap_x");
+ return output;
}
- template <typename I, typename O>
+ template <typename I>
inline
- void lap_o(const Image<I>& input, Image<O>& output)
+ mln_ch_convolve(I, int)
+ lap_o(const Image<I>& input)
{
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::lap_o");
+ mln_precondition(exact(input).has_data());
int ws[] = { -1, +2, -1,
+2, -4, +2,
-1, +2, -1 };
- convolve(input, make::w_window2d(ws), output);
+ mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
+ trace::exiting("linear::lap_o");
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/accu/convolve.hh
--- mln/accu/convolve.hh (revision 2779)
+++ mln/accu/convolve.hh (working copy)
@@ -52,7 +52,8 @@
*/
template <typename T1, typename T2,
typename R = mln_sum_x(T1, T2)>
- struct convolve : public mln::accu::internal::base< R, convolve<T1,T2,R> >
+ struct convolve : public mln::accu::internal::base< R, convolve<T1,T2,R> >,
+ private metal::converts_to< mln_sum_x(T1, T2), R >::check_t
{
typedef std::pair<T1,T2> argument;
1
0